import pymysql
class mysqlDeploy:
    # 连接数据库
    def __init__(self):
        self.host = "localhost"
        self.user = "root"
        self.pwd = ''
        self.db = 'xkyc'


    def mysqlConnect(self):
        conn = pymysql.connect(host=self.host, user=self.user, passwd=self.pwd, db=self.db, charset="utf8")
        cur = conn.cursor()
        return conn, cur

    def selectData(self,sql):
        conn, cur = self.mysqlConnect()

        try:
            cur.execute(sql)
        except:
            raise

        rows = cur.fetchall()

        return rows

    def insertInto(self,sql):

        conn,cur = self.mysqlConnect()
        try:
            cur.execute(sql)
            conn.commit()
        except:
            raise
        finally:
            cur.close()
            conn.close()

    def test(self):
        return 123